home *** CD-ROM | disk | FTP | other *** search
/ NetNews Offline 2 / NetNews Offline Volume 2.iso / news / comp / lang / c-part1 / 2595 < prev    next >
Encoding:
Internet Message Format  |  1996-08-05  |  2.1 KB

  1. Path: rover.ucs.ualberta.ca!mcbride
  2. From: mcbride@ee.ualberta.ca (Darin McBride)
  3. Newsgroups: comp.lang.c,comp.os.os2.programmer.misc
  4. Subject: Re: redefining stdout and stderr
  5. Followup-To: comp.lang.c,comp.os.os2.programmer.misc
  6. Date: 22 Jan 1996 18:15:08 GMT
  7. Organization: University of Alberta Electrical Engineering Department
  8. Message-ID: <4e0k7c$1tgm@pulp.ucs.ualberta.ca>
  9. References: <DKw9Cv.2x4@fyi.net>
  10. NNTP-Posting-Host: hp10.ee.ualberta.ca
  11. X-Newsreader: TIN [version 1.2 PL2]
  12.  
  13. fireresq@fyi.net wrote:
  14. > everyting I am doing is running on OS/2 Warp Connect and using the IBM 
  15. > Set++ compiler.
  16.  
  17. > I have a program that I have converted form an exe to a DLL.  I used many
  18. > printf's for debug and status information.
  19.  
  20. > What I want to do is cause stdout and stderr to go to a file but since 
  21. > this dll will be called from VisualAge I cannot redirect the output with >.
  22.  
  23. > I need to change the assocation of stdout and stderr programaticly.  I 
  24. > would be open for suggestions.
  25.  
  26. > I need a way to close stdout and stderr.  then reopen them redircted to a
  27. > file from inside my dll.
  28.  
  29. For future readability's sake, I recommend not doing this... you may not
  30. remember 6 months down the road why your printf's aren't printing
  31. anything...
  32.  
  33. I would recommend possibly something along the lines of creating a FILE*
  34. that was global, for example, FILE* mylog, and initializing it.  Then
  35. you would have to use fprintf(mylog, format, ...) rather than
  36. printf(format, ...).  It would require changes this way and I see why
  37. you may not want to do this, however being a maintanence programmer, I'd
  38. much rather read 'fprintf(mylog, "nValue is %d", nValue)' where I know
  39. it's in a logfile to 'printf("nValue is %d", nValue)' where I would
  40. assume it was going to stdout (i.e., the screen).
  41.  
  42. --
  43. Darin McBride:mcbride@ee.ualberta.ca/mcbride@tower.bohica.net
  44.  
  45. Enjoy each day as if it were your last, care about each moment as if
  46. it were your last for one day, one moment, you *will* be right!
  47.  
  48. Tips & Tricks for IBM Hardware, MSDOS, OS2, Windows (including Win'95):
  49.     http://www.ee.ualberta.ca/~mcbride/tiptrick.html
  50.